<title>修改密码</title>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>个人中心</cite></a>
        <a><cite>修改密码</cite></a>
    </div>
</div>

<style>
    .layui-table-cell{
        height: auto;
    }
    /*
    .layui-table-cell span{
        display: block;
    }
    .layui-table-cell img{
        width: 50px;
        margin-top: 20px;
    }
     */
</style>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">修改密码</div>
        <div class="layui-card-body" style="padding: 15px;">
            <div class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">旧密码</label>
                <div class="layui-input-block">
                    <script type="text/html" template>
                        <input type="password" name="old_password" lay-verify="required" autocomplete="off"  class="layui-input"  style="width: 60%;">
                    </script>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">新密码</label>
                <div class="layui-input-block">
                    <script type="text/html" template>
                        <input type="password" name="password" lay-verify="required"  autocomplete="off" class="layui-input"  style="width: 60%;">
                    </script>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">确认密码</label>
                <div class="layui-input-block">
                    <script type="text/html" template>
                        <input type="password" name="password_confirmation" lay-verify="required" autocomplete="off" class="layui-input"  style="width: 60%;">
                    </script>
                </div>
            </div>
            <div class="layui-input-block">
                <div class="">
                    <input type="button" lay-submit lay-filter="LAY-admin-password-button" value="确认" class="layui-btn">
                </div>

            </div>
            </div>
        </div>
    </div>
</div>

<script>
    layui.use(['form','admin'], function(){
        var $ = layui.$
            ,form = layui.form
            ,admin = layui.admin

        //修改密码
        form.on('submit(LAY-admin-password-button)', function(data){
            var field = data.field;

            console.log(field);

            admin.req({
                url:'home/password'
                ,type: 'post'
                ,data:field
                ,done:function (res) {
                    console.log(res);
                    if(res.code == 0) {
                        layer.msg('修改成功, 请重新登录');
                        admin.exit();
                    }

                }
            });


        });

    });
</script>
